package com.pengpai.pangucms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.pengpai.pangucms.entity.WebArticle;
import com.pengpai.pangucms.mapper.WebArticleMapper;
import com.pengpai.pangucms.service.IWebArticleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pengpai.pangucms.utils.PageDomain;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wushuai
 * @since 2023-09-01
 */
@Service
public class WebArticleServiceImpl extends ServiceImpl<WebArticleMapper, WebArticle> implements IWebArticleService {

    @Resource
    private WebArticleMapper webArticleMapper;

    @Override
    public PageInfo<WebArticle> page(WebArticle param, PageDomain pageDomain) {
        PageHelper.startPage(pageDomain.getPage(), pageDomain.getLimit());
        List<WebArticle> webArticles = list(new QueryWrapper<>(param));
        return new PageInfo<>(webArticles);
    }

    @Override
    public List<WebArticle> selectThreeArticle() {
        return webArticleMapper.selectThreeArticle();
    }
}
